package com.example;

import com.example.entity.Phone;
import com.example.entity.User;
import com.example.service.PhoneService;
import com.example.service.UserService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @Auther: ${USER}
 * @Date: ${YEAR}/${MONTH}/${DAY}/${TIME}
 * @Description:
 */
@Component
public class Main {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 对象
        User user = context.getBean(User.class);
        Phone phone = context.getBean(Phone.class);
        // service
        UserService userService = context.getBean(UserService.class);
        userService.addUser(user);
        userService.deleteUser(1);
        userService.updateUser(user);
        userService.getUserById(1);
        userService.testUser();

        PhoneService phoneService = context.getBean(PhoneService.class);
        phoneService.addPhone(phone);
        phoneService.deletePhone("1");
        phoneService.updatePhone(phone);
        phoneService.getPhoneByNumber("1");
        phoneService.testPhone();
    }
}